import redis
# 在不同的环境的配置下添加日志级别
import logging


class Config(object):
    # DEBUG = True  # 抽取出去,使其可变
    SQLALCHEMY_DATABASE_URI = "mysql://root:1234@127.0.0.1:3306/test2"
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    # redis配置
    HOST = "127.0.0.1"
    PORT = 6379

    # Session 将session数据保存到redis数据库中 配置
    SECRET_KEY = "Edskjafldml1231123123"

    SESSION_TYPE = "redis"
    SESSION_USER_SIGNER = True  # 被加密签名处理
    SESSION_REDIS = redis.StrictRedis(host=HOST, port=PORT)
    PERMANENT_SESSION_LIFETIME = 86400  # 设置有效时长


# 创建两个选择类,方便以后自动切换debug模式和生产模式
class Development(Config):
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class Production(Config):
    DEBUG = False
    LOG_LEVEL = logging.ERROR


# 定义字典,取值变得
config_dict = {"development": Development, "production": Production}
